package com.ncp.servlet.product;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ncp.model.biz.product.ManageBackstageProductBiz;
import com.ncp.model.entity.product.ProductUpdateBean;

public class ManagerBasicUpdServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html");
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		String type = request.getParameter("type");
		String update = request.getParameter("update");
		int ProductID = Integer.parseInt(request.getParameter("ProductID"));
		boolean b=false;

		if(update!=""){
			ProductUpdateBean pub = new ProductUpdateBean();
			
			pub.setProductID(ProductID);
			pub.setType(type);
			pub.setUpdate(update);	
			ManageBackstageProductBiz mbp =  new ManageBackstageProductBiz();
		if(type.equals("ProductSortFromSort")==false){
		
		
		
		b=mbp.setUpdateInfo(pub);
		}else if(type.equals("ProductSortFromSort")){
			
			b=mbp.setUpdateInfoFromSort(pub);
		}
		
		if(b==true){
			
			
			request.getRequestDispatcher("pages/admin/product/suc.jsp").forward(request,response);
			
		}else{
			request.getRequestDispatcher("pages/product/admin/err.jsp").forward(request,response);

		}
		
	  }
		else{
				request.getRequestDispatcher("pages/product/admin/warn.jsp").forward(request,response);

	
		}
	
	}
}
